package com.example.meeting.service.impl;

import com.example.meeting.mapper.PersonMapper;
import com.example.meeting.model.domain.Person;
import com.example.meeting.service.IPersonService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Slf4j
@Service
public class PersonServiceImpl implements IPersonService {
    @Autowired
    private PersonMapper personMapper;
    @Override
    public Person selectPersonByName(String name) {
        try {
            return personMapper.selectPersonByName(name);
        } catch (Exception e) {
            log.error("查询列席人员接口报错！{}", e.getMessage());
        }
        return null;
    }

    @Override
    public PageInfo<Person> selectPersonList(Integer page, Integer pageSize, Person person) {
        try {
            PageHelper.startPage(page,pageSize);
            List<Person> personList = personMapper.selectPersonList(person);
            return new PageInfo<>(personList);
        } catch (Exception e){
            log.error("查询列席人员接口报错！{}",e.getMessage());
        }
        return null;
    }

    @Override
    public List<Person> selectPersonListByIds(List<Long> ids) {
        try {
            return personMapper.selectPersonListByIds(ids);
        } catch (Exception e){
            log.error("批量查询列席人员接口报错！{}",e.getMessage());
        }
        return null;
    }

    @Override
    public Integer addPerson(Person person) {
        try {
            return personMapper.addPerson(person);
        } catch (Exception e){
            log.error("新增列席人员接口报错！{}",e.getMessage());
        }
        return 0;
    }


    @Override
    public Integer updatePerson(Person person) {
        try {
            return personMapper.updatePerson(person);
        } catch (Exception e) {
            log.error("更新列席人员接口报错！{}",e.getMessage());
        }
        return 0;
    }
}
